//
//  LJP_RecommendDetailsView.m
//  God_is_a_Girl
//
//  Created by 李继鹏 on 15/9/30.
//  Copyright (c) 2015年 呸. All rights reserved.
//

#import "LJP_RecommendDetailsView.h"
#import <UIImageView+WebCache.h>
#import "LJP_ DetailsHearderModel.h"
@implementation LJP_RecommendDetailsView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backPicture = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 200)];
        UIVisualEffectView *effect = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight ]];
        effect.frame = self.backPicture.frame;
        effect.alpha = 1;
        [self addSubview:_backPicture];
        [self addSubview:effect];
        self.headerPicture = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
        self.headerPicture.center = CGPointMake([UIScreen mainScreen].bounds.size.width / 2, 100);
        self.headerPicture.layer.cornerRadius = 30;
        self.headerPicture.layer.masksToBounds = YES;
        self.userName = [[UILabel alloc] initWithFrame:CGRectMake(0, 140, [UIScreen mainScreen].bounds.size.width, 20)];
        self.userName.textAlignment = NSTextAlignmentCenter;
        self.userName.font = [UIFont systemFontOfSize:13];
        self.userName.textColor = [UIColor colorWithRed:0.315 green:0.304 blue:0.336 alpha:1.000];
        self.time = [[UILabel alloc] initWithFrame:CGRectMake(20, 295, [UIScreen mainScreen].bounds.size.width / 2 - 30, 20)];
        self.distance = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width / 2 + 10, 295, [UIScreen mainScreen].bounds.size.width / 2 - 30, 20)];
        self.time.textAlignment = NSTextAlignmentCenter;
        self.distance.textAlignment = NSTextAlignmentCenter;
        self.time.font = [UIFont fontWithName:@"Helvetica" size:18];
        self.distance.font = [UIFont fontWithName:@"Helvetica" size:18];
        self.name = [[UILabel alloc] initWithFrame:CGRectMake(20, 200, [UIScreen mainScreen].bounds.size.width - 40, 60)];
        self.name.textAlignment = NSTextAlignmentCenter;
        self.name.font = [UIFont fontWithName:@"Helvetica-Bold" size:22];
        self.name.textColor = [UIColor colorWithRed:0.455 green:0.941 blue:0.844 alpha:1.000];
        _name.numberOfLines = 0;
        self.way = [[UILabel alloc] initWithFrame:CGRectMake(0, 260, [UIScreen mainScreen].bounds.size.width, 20)];
        self.way.textAlignment = NSTextAlignmentCenter;
        self.way.font = [UIFont systemFontOfSize:15];
        self.way.numberOfLines = 0;
        [self addSubview:_headerPicture];
        [self addSubview:self.userName];
        [self addSubview:self.time];
        [self addSubview:self.distance];
        [self addSubview:self.name];
        [self addSubview:self.way];
        
    }
    return self;
}
- (void)setModel:(LJP__DetailsHearderModel *)model
{
    if (model != _model) {
        _model = model;
    }
    if (_model != nil) {
        
        [self.backPicture sd_setImageWithURL:[NSURL URLWithString:_model.cover_image] placeholderImage:[UIImage imageNamed:@"search"]];
        [self.headerPicture sd_setImageWithURL:[NSURL URLWithString:_model.avatar_m] placeholderImage:[UIImage imageNamed:@"search"]];
        self.name.text = _model.name;
        self.userName.text = _model.userName;
        self.time.text = [NSString stringWithFormat:@"行程%@天", _model.day_count.stringValue];
        self.distance.text = [NSString stringWithFormat:@"历程%.f公里", _model.mileage.floatValue];
        self.way.text = [NSString stringWithFormat:@"%@ ~ %@", _model.first_day, _model.last_day];
//        self.way.text = temp;
    }
}


@end
